<?php
declare (strict_types = 1);

namespace app\api\controller\v1;

use app\api\traits\Curd;
use app\api\controller\ApiController;
use app\api\model\SupplyBanner;
use app\api\service\ApiResponse;
use think\facade\Cache;

class Banners extends ApiController
{
    protected $middleware = ['Token'];
    protected $modelName = 'SupplyBanner';
    protected $validate = 'Banner';   //线索表验证器
   
    use Curd;
    public function index()
    {
        if (Cache::store('redis')->has('banner') == false) {
            $select = SupplyBanner::select();
            // 使用Redis缓存
            Cache::store('redis')->set('banner', $select);
            $banner = Cache::store('redis')->get('banner');     
        } else {
            $banner = Cache::store('redis')->get('banner');
        }
        return ApiResponse::success($banner); 
    }
}
